<template>
  <div class="wrapper">
    <div class="top-row">
      <div class="name">{{ dataArr[0].xm }}</div>
      <div class="value-wrapper">
        <span>{{ dataArr[0].sz }}</span>
        <span>{{ dataArr[0].dw }}</span>
      </div>
      <div class="rate rate--up">{{ dataArr[1].sz + dataArr[1].dw }}</div>
    </div>
    <h3 class="title">各区县机动车注册登记数量</h3>
    <VehiclesRegistrationChart />
  </div>
</template>

<script>
import { getAction } from '@/api/manage'
import VehiclesRegistrationChart from './VehiclesRegistrationChart.vue'

export default {
  name: 'VehiclesRegistration',
  components: {
    VehiclesRegistrationChart
  },
  data() {
    return {
      dataArr: [[], []]
    }
  },
  created() {
    this.loadData()
  },
  methods: {
    async loadData() {
      const res = await getAction(
        '/topic/data/listAllBySql/dy_ydd_jtys_dfjtys_gk',
        { lb: '机动车注册登记情况' }
      )
      if (res.success) {
        this.dataArr = res.result
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.wrapper {
  height: 100%;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 4px;

  .top-row {
    padding: 0 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 49px;
    background: url('../../images/left/l-row-bg.png') no-repeat;
    background-size: 100% 100%;

    .name {
      font-family: MicrosoftYaHeiUI;
      font-size: 16px;
      color: #ffffff;
    }
    .value-wrapper {
      display: flex;
      align-items: center;

      span:first-child {
        margin-right: 4px;
        font-family: YouSheBiaoTiHei;
        font-size: 24px;
        color: #ffde00;
        line-height: 1.5;
      }
      span:last-child {
        font-family: MicrosoftYaHeiUI;
        font-size: 14px;
        color: #ffffff;
      }
    }
    .rate {
      display: flex;
      align-items: center;
      font-family: MicrosoftYaHeiUI, MicrosoftYaHeiUI;
      font-weight: bold;
      font-size: 16px;
      color: #ff3e3e;

      &::before {
        margin-right: 4px;
        display: block;
        width: 10px;
        height: 14px;
        background: url('../../images/left/up-arrow.png') no-repeat;
        background-size: 100% 100%;
        content: '';
      }
    }
  }

  h3.title {
    margin-top: 10px;
    padding-left: 15px;
    width: 420px;
    height: 31px;
    display: flex;
    align-items: center;
    background: url('../../images/left/secondary-title-bg.png') no-repeat;
    font-family: MicrosoftYaHeiUI, MicrosoftYaHeiUI;
    font-weight: bold;
    font-size: 16px;
    color: #ffffff;
  }
}
</style>
